#######################
#######################
###Robustness Models###
#######################
#######################

##############################
###Confirmed Incidents Only###
##############################
######Armed conflict
####State
lm3.state.c<-felm(formula=acled_battle_state ~ 
                  log.nl + logged.pop +
                  lagacled_battle_state + t  +
                  p_anom+spei+confirm+t_anom+
                  logLifeExpectancy+GovEff+logGDPpc
                |gid+month|0|gid,
                data=full.1996.2019)
summary(lm3.state.c)
####Rebel
lm3.rebel.c<-felm(formula=acled_battle_rebel ~ 
                  log.nl + logged.pop +
                  lagacled_battle_rebel + t  +
                  p_anom+spei+confirm+t_anom+
                  logLifeExpectancy+GovEff+logGDPpc
                |gid+month|0|gid,
                data=full.1996.2019)
summary(lm3.rebel.c)

######Social conflict
###Political
lm3.mil.pol.c<-felm(formula=acled_battle_polmil ~ 
                    log.nl + logged.pop +
                    lagacled_battle_polmil + t  +
                    p_anom+spei+confirm+t_anom+
                    logLifeExpectancy+GovEff+logGDPpc
                  |gid+month|0|gid,
                  data=full.1996.2019)
summary(lm3.mil.pol.c)
###Identity
lm3.mil.id.c<-felm(formula=acled_battle_idmil ~ 
                   log.nl + logged.pop +
                   lagacled_battle_idmil + t  +
                   p_anom+spei+confirm+t_anom+
                   logLifeExpectancy+GovEff+logGDPpc
                 |gid+month|0|gid,
                 data=full.1996.2019)
summary(lm3.mil.id.c)

###Export to LaTex 
stargazer(lm3.state.c,lm3.rebel.c,lm3.mil.pol.c, lm3.mil.id.c, ci = TRUE)

##Export p-values
p.val1<-cbind(summary(lm3.state.c)$coefficients[,4],summary(lm3.rebel.c)$coefficients[,4],summary(lm3.mil.pol.c)$coefficients[,4],summary(lm3.mil.id.c)$coefficients[,4])
round(p.val1, digits = 3)

################
###1997-2019 ###
################
full.1997.2019 <- subset(full.1996.2019, year>=1997)
######Armed conflict
####State
lm1.state<-felm(formula=acled_battle_state ~ 
                  p_anom+outbreak+t_anom+spei
                |gid+month|0|gid,
                data=full.1997.2019)
summary(lm1.state)
####Rebel
lm1.rebel<-felm(formula=acled_battle_rebel ~ 
                  p_anom+outbreak+t_anom+spei
                |gid+month|0|gid,
                data=full.1997.2019)
summary(lm1.rebel)

#####Social conflict
###Political
lm1.mil.pol<-felm(formula=acled_battle_polmil ~ 
                    p_anom+outbreak+t_anom+spei
                  |gid+month|0|gid,
                  data=full.1997.2019)
summary(lm1.mil.pol)
###Identity
lm1.mil.id<-felm(formula=acled_battle_idmil ~ 
                   p_anom+outbreak+t_anom+spei
                 |gid+month|0|gid,
                 data=full.1997.2019)
summary(lm1.mil.id)

##Export to LaTex
stargazer(lm1.state,lm1.rebel,lm1.mil.pol, lm1.mil.id, ci = TRUE)

##Export p-values
p.val2<-cbind(summary(lm1.state)$coefficients[,4],summary(lm1.rebel)$coefficients[,4],summary(lm1.mil.pol)$coefficients[,4],summary(lm1.mil.id)$coefficients[,4])
round(p.val2, digits = 3)


####################
###Just 2013-2019###
####################
full.2013.2019 <- subset(full.1996.2019, (year>=2013&year<=2019))
######Armed conflict
####State
lm3.state.s<-felm(formula=acled_battle_state ~ 
                  log.nl + logged.pop +
                  lagacled_battle_state + t  +
                  p_anom+spei+outbreak+t_anom+
                  logLifeExpectancy+GovEff+logGDPpc
                |gid+month|0|gid,
                data=full.2013.2019)
summary(lm3.state.s)
####Rebel
lm3.rebel.s<-felm(formula=acled_battle_rebel ~ 
                  log.nl + logged.pop +
                  lagacled_battle_rebel + t  +
                  p_anom+spei+outbreak+t_anom+
                  logLifeExpectancy+GovEff+logGDPpc
                |gid+month|0|gid,
                data=full.2013.2019)
summary(lm3.rebel.s)

######Social conflict
###Political
lm3.mil.pol.s<-felm(formula=acled_battle_polmil ~ 
                    log.nl + logged.pop +
                    lagacled_battle_polmil + t  +
                    p_anom+spei+outbreak+t_anom+
                    logLifeExpectancy+GovEff+logGDPpc
                  |gid+month|0|gid,
                  data=full.2013.2019)
summary(lm3.mil.pol.s)
###Identity
lm3.mil.id.s<-felm(formula=acled_battle_idmil ~ 
                   log.nl + logged.pop +
                   lagacled_battle_idmil + t  +
                   p_anom+spei+outbreak+t_anom+
                   logLifeExpectancy+GovEff+logGDPpc
                 |gid+month|0|gid,
                 data=full.2013.2019)
summary(lm3.mil.id.s)

##Export to LaTex
stargazer(lm3.state.s,lm3.rebel.s,lm3.mil.pol.s, lm3.mil.id.s, ci = TRUE)

##Export p-values
p.val3<-cbind(summary(lm3.state.s)$coefficients[,4],summary(lm3.rebel.s)$coefficients[,4],summary(lm3.mil.pol.s)$coefficients[,4],summary(lm3.mil.id.s)$coefficients[,4])
round(p.val3, digits = 3)

##############################
###Country Fragilities Only###
##############################
######Armed conflict
####State
lm3.state.nd<-felm(formula=acled_battle_state ~ 
                     log.nl + logged.pop  +
                     p_anom+spei+outbreak+t_anom+
                     logLifeExpectancy+GovEff+logGDPpc
                   |gid+month|0|gid,
                   data=full.1996.2019)
summary(lm3.state.nd)
####Rebel
lm3.rebel.nd<-felm(formula=acled_battle_rebel ~ 
                     log.nl + logged.pop   +
                     p_anom+spei+outbreak+t_anom+
                     logLifeExpectancy+GovEff+logGDPpc
                   |gid+month|0|gid,
                   data=full.1996.2019)
summary(lm3.rebel.nd)

######Social conflict
###Political
lm3.mil.pol.nd<-felm(formula=acled_battle_polmil ~ 
                       log.nl + logged.pop   +
                       p_anom+spei+outbreak+t_anom+
                       logLifeExpectancy+GovEff+logGDPpc
                     |gid+month|0|gid,
                     data=full.1996.2019)
summary(lm3.mil.pol.nd)
###Identity
lm3.mil.id.nd<-felm(formula=acled_battle_idmil ~ 
                      log.nl + logged.pop  +
                      p_anom+spei+outbreak+t_anom+
                      logLifeExpectancy+GovEff+logGDPpc
                    |gid+month|0|gid,
                    data=full.1996.2019)
summary(lm3.mil.id.nd)


##Export to LaTex
stargazer(lm3.state.nd,lm3.rebel.nd,lm3.mil.pol.nd, lm3.mil.id.nd, ci = TRUE)

##Export p-values
p.val4<-cbind(summary(lm3.state.nd)$coefficients[,4],summary(lm3.rebel.nd)$coefficients[,4],summary(lm3.mil.pol.nd)$coefficients[,4],summary(lm3.mil.id.nd)$coefficients[,4])
round(p.val4, digits = 3)



######################
###Binary Outbreak ###
######################
full.1996.2019$outbreak_bin <- ifelse(full.1996.2019$outbreak>0,1,0)
######Armed conflict
####State
lm3.state.bin<-felm(formula=acled_battle_state ~ 
                      log.nl + logged.pop +
                      lagacled_battle_state + t  +
                      p_anom+spei+outbreak_bin+t_anom+
                      logLifeExpectancy+GovEff+logGDPpc
                    |gid+month|0|gid,
                    data=full.1996.2019)
summary(lm3.state.bin)
####Rebel
lm3.rebel.bin<-felm(formula=acled_battle_rebel ~ 
                      log.nl + logged.pop +
                      lagacled_battle_rebel + t  +
                      p_anom+spei+outbreak_bin+t_anom+
                      logLifeExpectancy+GovEff+logGDPpc
                    |gid+month|0|gid,
                    data=full.1996.2019)
summary(lm3.rebel.bin)

######Social conflict
###Political
lm3.mil.pol.bin<-felm(formula=acled_battle_polmil ~ 
                        log.nl + logged.pop +
                        lagacled_battle_polmil + t  +
                        p_anom+spei+outbreak_bin+t_anom+
                        logLifeExpectancy+GovEff+logGDPpc
                      |gid+month|0|gid,
                      data=full.1996.2019)
summary(lm3.mil.pol.bin)
###Identity
lm3.mil.id.bin<-felm(formula=acled_battle_idmil ~ 
                       log.nl + logged.pop +
                       lagacled_battle_idmil + t  +
                       p_anom+spei+outbreak_bin+t_anom+
                       logLifeExpectancy+GovEff+logGDPpc
                     |gid+month|0|gid,
                     data=full.1996.2019)
summary(lm3.mil.id.bin)

###Export to LaTex 
stargazer(lm3.state.bin,lm3.rebel.bin,lm3.mil.pol.bin, lm3.mil.id.bin, ci = TRUE)

##Export p-values
p.val5<-cbind(summary(lm3.state.bin)$coefficients[,4],summary(lm3.rebel.bin)$coefficients[,4],summary(lm3.mil.pol.bin)$coefficients[,4],summary(lm3.mil.id.bin)$coefficients[,4])
round(p.val5, digits = 3)


##############################
###Environmental Pestilence###
##############################
######Armed conflict
####State
lm2.state.int<-felm(formula=acled_battle_state ~ 
                      log.nl + logged.pop +
                      lagacled_battle_state + t  +
                      p_anom+spei+outbreak+t_anom+
                      p_anom*outbreak+
                      logLifeExpectancy+GovEff+logGDPpc
                    |gid+month|0|gid,
                    data=full.1996.2019)
summary(lm2.state.int)
####Rebel
lm2.rebel.int<-felm(formula=acled_battle_rebel ~ 
                      log.nl + logged.pop +
                      lagacled_battle_rebel + t  +
                      p_anom+spei+outbreak+t_anom+
                      p_anom*outbreak+
                      logLifeExpectancy+GovEff+logGDPpc
                    |gid+month|0|gid,
                    data=full.1996.2019)
summary(lm2.rebel.int)

#####Social conflict
###Political
lm2.mil.pol.int<-felm(formula=acled_battle_polmil ~ 
                        log.nl + logged.pop +
                        lagacled_battle_polmil + t  +
                        p_anom+spei+outbreak+t_anom+
                        p_anom*outbreak+
                        logLifeExpectancy+GovEff+logGDPpc
                      |gid+month|0|gid,
                      data=full.1996.2019)
summary(lm2.mil.pol.int)
###Identity
lm2.mil.id.int<-felm(formula=acled_battle_idmil ~ 
                       log.nl + logged.pop +
                       lagacled_battle_idmil + t  +
                       p_anom+spei+outbreak+t_anom+
                       p_anom*outbreak+
                       logLifeExpectancy+GovEff+logGDPpc
                     |gid+month|0|gid,
                     data=full.1996.2019)
summary(lm2.mil.id.int)

###Export to LaTex
stargazer(lm2.state.int, lm2.rebel.int, lm2.mil.pol.int, lm2.mil.id.int, ci = TRUE)

##Export p-values
p.val6<-cbind(summary(lm2.state.int)$coefficients[,4],summary(lm2.rebel.int)$coefficients[,4],summary(lm2.mil.pol.int)$coefficients[,4],summary(lm2.mil.id.int)$coefficients[,4])
round(p.val6, digits = 3)


##########################
###Other actor controls###
##########################
######Armed conflict
####State
lm3.state.cont<-felm(formula=acled_battle_state ~ 
                       log.nl + logged.pop +
                       lagacled_battle_state + t  + 
                       acled_battle_rebel+ acled_battle_polmil+
                       acled_battle_idmil + 
                       p_anom+spei+outbreak+t_anom+
                       logLifeExpectancy+GovEff+logGDPpc
                     |gid+month|0|gid,
                     data=full.1996.2019)
summary(lm3.state.cont)
####Rebel
lm3.rebel.cont<-felm(formula=acled_battle_rebel ~ 
                       log.nl + logged.pop +
                       lagacled_battle_rebel + t  +
                       acled_battle_state+ acled_battle_polmil+
                       acled_battle_idmil +
                       p_anom+spei+outbreak+t_anom+
                       logLifeExpectancy+GovEff+logGDPpc
                     |gid+month|0|gid,
                     data=full.1996.2019)
summary(lm3.rebel.cont)

######Social conflict
###Political
lm3.mil.pol.cont<-felm(formula=acled_battle_polmil ~ 
                         log.nl + logged.pop +
                         lagacled_battle_polmil + t  +
                         acled_battle_state + acled_battle_rebel +
                         acled_battle_idmil+
                         p_anom+spei+outbreak+t_anom+
                         logLifeExpectancy+GovEff+logGDPpc
                       |gid+month|0|gid,
                       data=full.1996.2019)
summary(lm3.mil.pol.cont)
###Identity
lm3.mil.id.cont<-felm(formula=acled_battle_idmil ~ 
                        log.nl + logged.pop +
                        lagacled_battle_idmil + t  +
                        acled_battle_state + acled_battle_rebel +
                        acled_battle_polmil + 
                        p_anom+spei+outbreak+t_anom+
                        logLifeExpectancy+GovEff+logGDPpc
                      |gid+month|0|gid,
                      data=full.1996.2019)
summary(lm3.mil.id.cont)

###Export to LaTex
stargazer(lm3.state.cont, lm3.rebel.cont, lm3.mil.pol.cont, lm3.mil.id.cont, ci = TRUE)

##Export p-values
p.val7<-cbind(summary(lm3.state.cont)$coefficients[,4],summary(lm3.rebel.cont)$coefficients[,4],summary(lm3.mil.pol.cont)$coefficients[,4],summary(lm3.mil.id.cont)$coefficients[,4])
round(p.val7, digits = 3)

####################################
###Other actor conflict with lags###
####################################
######Armed conflict
####State
lm3.state.cl<-felm(formula=acled_battle_state ~ 
                          log.nl + logged.pop +
                          lagacled_battle_state + t  + 
                          acled_battle_rebel+ acled_battle_polmil+
                          acled_battle_idmil + 
                          lagacled_battle_rebel+ lagacled_battle_polmil+
                          lagacled_battle_idmil + 
                          p_anom+spei+outbreak+t_anom+
                          logLifeExpectancy+GovEff+logGDPpc
                        |gid+month|0|gid,
                        data=full.1996.2019)
summary(lm3.state.cl)
####Rebel
lm3.rebel.cl<-felm(formula=acled_battle_rebel ~ 
                          log.nl + logged.pop +
                          lagacled_battle_rebel + t  +
                          acled_battle_state+ acled_battle_polmil+
                          acled_battle_idmil +
                          lagacled_battle_state+lagacled_battle_polmil+
                          lagacled_battle_idmil +
                          p_anom+spei+outbreak+t_anom+
                          logLifeExpectancy+GovEff+logGDPpc
                        |gid+month|0|gid,
                        data=full.1996.2019)
summary(lm3.rebel.cl)

######Social conflict
###Political
lm3.mil.pol.cl<-felm(formula=acled_battle_polmil ~ 
                            log.nl + logged.pop +
                            lagacled_battle_polmil + t  +
                            acled_battle_state + acled_battle_rebel +
                            acled_battle_idmil+
                            lagacled_battle_state + lagacled_battle_rebel +
                            lagacled_battle_idmil+
                            p_anom+spei+outbreak+t_anom+
                            logLifeExpectancy+GovEff+logGDPpc
                          |gid+month|0|gid,
                          data=full.1996.2019)
summary(lm3.mil.pol.cl)
###Identity
lm3.mil.id.cl<-felm(formula=acled_battle_idmil ~ 
                           log.nl + logged.pop +
                           lagacled_battle_idmil + t  +
                           acled_battle_state + acled_battle_rebel +
                           acled_battle_polmil + 
                           lagacled_battle_state +lagacled_battle_rebel +
                           lagacled_battle_polmil + 
                           p_anom+spei+outbreak+t_anom+
                           logLifeExpectancy+GovEff+logGDPpc
                         |gid+month|0|gid,
                         data=full.1996.2019)
summary(lm3.mil.id.cl)

###Export to LaTex
stargazer(lm3.state.cl, lm3.rebel.cl, lm3.mil.pol.cl, lm3.mil.id.cl, ci = TRUE)

##Export p-values
p.val8<-cbind(summary(lm3.state.cl)$coefficients[,4],summary(lm3.rebel.cl)$coefficients[,4],summary(lm3.mil.pol.cl)$coefficients[,4],summary(lm3.mil.id.cl)$coefficients[,4])
round(p.val8, digits = 3)

###################
###With Covid-19###
###################
####Import covid 2020 data
setwd("~/OneDrive - Indiana University/FromGoogle/GeolocatedDisease/")
full2020 <- read.csv("disease_conf_2020_10_3_23.csv")
summary(full2020)
##Subset only relevant variables for each data
#Full dataset
full.1996.2019.s <- full.1996.2019[,c("acled_battle_state","acled_battle_rebel","acled_battle_polmil","acled_battle_idmil","outbreak","t","lagacled_battle_state","lagacled_battle_rebel","lagacled_battle_polmil","lagacled_battle_idmil","log.nl","logged.pop","spei","p_anom","t_anom","logLifeExpectancy","GovEff","logGDPpc","year","month","gid")]
#new dataset
full2020.s <- full2020[,c("acled_battle_state","acled_battle_rebel","acled_battle_polmil","acled_battle_idmil","outbreak","t","lagacled_battle_state","lagacled_battle_rebel","lagacled_battle_polmil","lagacled_battle_idmil","log.nl","logged.pop","spei","p_anom","t_anom","logLifeExpectancy","GovEff","logGDPpc","year","month","gid")]

#Combine datasets
full.1996.2020.s <- data.frame(rbind(full.1996.2019.s,full2020.s))
summary(full.1996.2020.s)

###Check what data is available for Jan-March 2020
sum.dat <- summaryBy(log.nl+logged.pop+p_anom+spei+t_anom+
                       logLifeExpectancy+GovEff+logGDPpc~year, data=full.1996.2020.s, na.rm=T)
sum.dat

######Armed conflict
####State
lm3.state.cov<-felm(formula=acled_battle_state ~ 
                  outbreak+t+lagacled_battle_state+
                    logged.pop+p_anom+t_anom+
                    logLifeExpectancy+GovEff+logGDPpc
                |gid+month|0|gid,
                data=full.1996.2020.s)
summary(lm3.state.cov)
####Rebel
lm3.rebel.cov<-felm(formula=acled_battle_rebel ~ 
                  outbreak+t+lagacled_battle_rebel+
                    logged.pop+p_anom+t_anom+
                  logLifeExpectancy+GovEff+logGDPpc
                |gid+month|0|gid,
                data=full.1996.2020.s)
summary(lm3.rebel.cov)

#####Social conflict
###Political
lm3.mil.pol.cov<-felm(formula=acled_battle_polmil ~ 
                    outbreak +t+lagacled_battle_polmil+
                      logged.pop+p_anom+t_anom+
                    logLifeExpectancy+GovEff+logGDPpc
                  |gid+month|0|gid,
                  data=full.1996.2020.s)
summary(lm3.mil.pol.cov)
###Identity
lm3.mil.id.cov<-felm(formula=acled_battle_idmil ~ 
                   outbreak +t +lagacled_battle_idmil+
                     logged.pop+p_anom+t_anom+
                   logLifeExpectancy+GovEff+logGDPpc
                 |gid+month|0|gid,
                 data=full.1996.2020.s)
summary(lm3.mil.id.cov)

##Export to LaTex
stargazer(lm3.state.cov,lm3.rebel.cov,lm3.mil.pol.cov, lm3.mil.id.cov, ci = TRUE)


##Export p-values
p.val9<-cbind(summary(lm3.state.cov)$coefficients[,4],summary(lm3.rebel.cov)$coefficients[,4],summary(lm3.mil.pol.cov)$coefficients[,4],summary(lm3.mil.id.cov)$coefficients[,4])
round(p.val9, digits = 3)

##################
##################
###By virulence###
##################
##################

###################
###Most Virulent###
###################
#Create indicator
full.1996.2019$virulent <- full.1996.2019$ebola_zaire + full.1996.2019$ebola_other + full.1996.2019$bubonic_plague+full.1996.2019$septicaemic_plague +full.1996.2019$marburg+ full.1996.2019$rabies + full.1996.2019$cc_haemorrhagic_fever+full.1996.2019$anthrax
sum(full.1996.2019$virulent)
######Armed conflict
####State
lm3.state.hem<-felm(formula=acled_battle_state ~ 
                      log.nl + logged.pop +
                      lagacled_battle_state + t  +
                      p_anom+spei+virulent+t_anom+
                      logLifeExpectancy+GovEff+logGDPpc
                    |gid+month|0|gid,
                    data=full.1996.2019)
summary(lm3.state.hem)
####Rebel
lm3.rebel.hem<-felm(formula=acled_battle_rebel ~ 
                      log.nl + logged.pop +
                      lagacled_battle_rebel + t  +
                      p_anom+spei+virulent+t_anom+
                      logLifeExpectancy+GovEff+logGDPpc
                    |gid+month|0|gid,
                    data=full.1996.2019)
summary(lm3.rebel.hem)

######Social conflict
###Political
lm3.mil.pol.hem<-felm(formula=acled_battle_polmil ~ 
                        log.nl + logged.pop +
                        lagacled_battle_polmil + t  +
                        p_anom+spei+virulent+t_anom+
                        logLifeExpectancy+GovEff+logGDPpc
                      |gid+month|0|gid,
                      data=full.1996.2019)
summary(lm3.mil.pol.hem)
###Identity
lm3.mil.id.hem<-felm(formula=acled_battle_idmil ~ 
                       log.nl + logged.pop +
                       lagacled_battle_idmil + t  +
                       p_anom+spei+virulent+t_anom+
                       logLifeExpectancy+GovEff+logGDPpc
                     |gid+month|0|gid,
                     data=full.1996.2019)
summary(lm3.mil.id.hem)


###Export to LaTex 
stargazer(lm3.state.hem,lm3.rebel.hem, lm3.mil.pol.hem, lm3.mil.id.hem, ci = TRUE)

##Export p-values
p.val10<-cbind(summary(lm3.state.hem)$coefficients[,4],summary(lm3.rebel.hem)$coefficients[,4],summary(lm3.mil.pol.hem)$coefficients[,4],summary(lm3.mil.id.hem)$coefficients[,4])
round(p.val10, digits = 3)

############################
###Fevers and Resp. Synd.###
############################
##Create indicator
full.1996.2019$fevers <- full.1996.2019$yellow_fever + full.1996.2019$rift_valley_fever + full.1996.2019$SARS + full.1996.2019$MERS+full.1996.2019$lassa_fever+full.1996.2019$dengue
sum(full.1996.2019$fevers)
######Armed conflict
####State
lm3.state.fev<-felm(formula=acled_battle_state ~ 
                         log.nl + logged.pop +
                         lagacled_battle_state + t  +
                         p_anom+spei+fevers+t_anom+
                         logLifeExpectancy+GovEff+logGDPpc
                       |gid+month|0|gid,
                       data=full.1996.2019)
summary(lm3.state.fev)
####Rebel
lm3.rebel.fev<-felm(formula=acled_battle_rebel ~ 
                         log.nl + logged.pop +
                         lagacled_battle_rebel + t  +
                         p_anom+spei+fevers+t_anom+
                         logLifeExpectancy+GovEff+logGDPpc
                       |gid+month|0|gid,
                       data=full.1996.2019)
summary(lm3.rebel.fev)

######Social conflict
###Political
lm3.mil.pol.fev<-felm(formula=acled_battle_polmil ~ 
                           log.nl + logged.pop +
                           lagacled_battle_polmil + t  +
                           p_anom+spei+fevers+t_anom+
                           logLifeExpectancy+GovEff+logGDPpc
                         |gid+month|0|gid,
                         data=full.1996.2019)
summary(lm3.mil.pol.fev)
###Identity
lm3.mil.id.fev<-felm(formula=acled_battle_idmil ~ 
                          log.nl + logged.pop +
                          lagacled_battle_idmil + t  +
                          p_anom+spei+fevers+t_anom+
                          logLifeExpectancy+GovEff+logGDPpc
                        |gid+month|0|gid,
                        data=full.1996.2019)
summary(lm3.mil.id.fev)


###Export to LaTex 
stargazer(lm3.state.fev,lm3.rebel.fev, lm3.mil.pol.fev, lm3.mil.id.fev, ci = TRUE)

##Export p-values
p.val11<-cbind(summary(lm3.state.fev)$coefficients[,4],summary(lm3.rebel.fev)$coefficients[,4],summary(lm3.mil.pol.fev)$coefficients[,4],summary(lm3.mil.id.fev)$coefficients[,4])
round(p.val11, digits = 3)

############
###Others###
############
##Create indicator
full.1996.2019$other_out <- full.1996.2019$outbreak - full.1996.2019$virulent - full.1996.2019$fevers
sum(full.1996.2019$other_out)
######Armed conflict
####State
lm3.state.ot<-felm(formula=acled_battle_state ~ 
                            log.nl + logged.pop +
                            lagacled_battle_state + t  +
                            p_anom+spei+other_out+t_anom+
                            logLifeExpectancy+GovEff+logGDPpc
                          |gid+month|0|gid,
                          data=full.1996.2019)
summary(lm3.state.ot)
####Rebel
lm3.rebel.ot<-felm(formula=acled_battle_rebel ~ 
                            log.nl + logged.pop +
                            lagacled_battle_rebel + t  +
                            p_anom+spei+other_out+t_anom+
                            logLifeExpectancy+GovEff+logGDPpc
                          |gid+month|0|gid,
                          data=full.1996.2019)
summary(lm3.rebel.ot)

######Social conflict
###Political
lm3.mil.pol.ot<-felm(formula=acled_battle_polmil ~ 
                              log.nl + logged.pop +
                              lagacled_battle_polmil + t  +
                              p_anom+spei+other_out+t_anom+
                              logLifeExpectancy+GovEff+logGDPpc
                            |gid+month|0|gid,
                            data=full.1996.2019)
summary(lm3.mil.pol.ot)
###Identity
lm3.mil.id.ot<-felm(formula=acled_battle_idmil ~ 
                             log.nl + logged.pop +
                             lagacled_battle_idmil + t  +
                             p_anom+spei+other_out+t_anom+
                             logLifeExpectancy+GovEff+logGDPpc
                           |gid+month|0|gid,
                           data=full.1996.2019)
summary(lm3.mil.id.ot)


###Export to LaTex 
stargazer(lm3.state.ot,lm3.rebel.ot, lm3.mil.pol.ot, lm3.mil.id.ot, ci = TRUE)

##Export p-values
p.val12<-cbind(summary(lm3.state.ot)$coefficients[,4],summary(lm3.rebel.ot)$coefficients[,4],summary(lm3.mil.pol.ot)$coefficients[,4],summary(lm3.mil.id.ot)$coefficients[,4])
round(p.val12, digits = 3)

##################################
###Aggregated Conflict Measures###
##################################
##Create a combined measure 
full.1996.2019$acled_battle_all <- full.1996.2019$acled_battle_state+full.1996.2019$acled_battle_rebel+full.1996.2019$acled_battle_polmil+full.1996.2019$acled_battle_idmil
full.1996.2019$lagacled_battle_all <- full.1996.2019$lagacled_battle_state+full.1996.2019$lagacled_battle_rebel+full.1996.2019$lagacled_battle_polmil+full.1996.2019$lagacled_battle_idmil
###Baseline###
lm2.all<-felm(formula=acled_battle_all ~ 
                log.nl + logged.pop +
                lagacled_battle_all + t  +
                p_anom+spei+outbreak+t_anom
              |gid+month|0|gid,
              data=full.1996.2019)
summary(lm2.all)
###Country Controls
lm3.all<-felm(formula=acled_battle_all ~ 
                log.nl + logged.pop +
                lagacled_battle_all + t  +
                p_anom+spei+outbreak+t_anom+
                logLifeExpectancy+GovEff+logGDPpc
              |gid+month|0|gid,
              data=full.1996.2019)
summary(lm3.all)

#Export to Latex
stargazer(lm2.all,lm3.all, ci = TRUE)

##Export p-values
p.val13<-cbind(summary(lm2.all)$coefficients[,4],summary(lm3.all)$coefficients[,4])
round(p.val13, digits = 3)


#################################
###Log and Sqaure Log Rainfall###
#################################
##Create log rainfall and its quadratic term
full.1996.2019$logp_avg <- log(full.1996.2019$p_avg+1)
full.1996.2019$logp_avgsq <- full.1996.2019$logp_avg^2

#######Run models
######Armed conflict
####State
lm3.state.quad<-felm(formula=acled_battle_state ~ 
                       log.nl + logged.pop +
                       lagacled_battle_state + t  +
                       logp_avg+logp_avgsq+spei+outbreak+t_anom+
                       logLifeExpectancy+GovEff+logGDPpc
                     |gid+month|0|gid,
                     data=full.1996.2019)
summary(lm3.state.quad)
####Rebel
lm3.rebel.quad<-felm(formula=acled_battle_rebel ~ 
                       log.nl + logged.pop +
                       lagacled_battle_rebel + t  +
                       logp_avg+logp_avgsq+spei+outbreak+t_anom+
                       logLifeExpectancy+GovEff+logGDPpc
                     |gid+month|0|gid,
                     data=full.1996.2019)
summary(lm3.rebel.quad)

######Social conflict
###Political
lm3.mil.pol.quad<-felm(formula=acled_battle_polmil ~ 
                         log.nl + logged.pop +
                         lagacled_battle_polmil + t  +
                         logp_avg+logp_avgsq+spei+outbreak+t_anom+
                         logLifeExpectancy+GovEff+logGDPpc
                       |gid+month|0|gid,
                       data=full.1996.2019)
summary(lm3.mil.pol.quad)
###Identity
lm3.mil.id.quad<-felm(formula=acled_battle_idmil ~ 
                        log.nl + logged.pop +
                        lagacled_battle_idmil + t  +
                        logp_avg+logp_avgsq+spei+outbreak+t_anom+
                        logLifeExpectancy+GovEff+logGDPpc
                      |gid+month|0|gid,
                      data=full.1996.2019)
summary(lm3.mil.id.quad)

###Export to LaTex 
stargazer(lm3.state.quad,lm3.rebel.quad,lm3.mil.pol.quad, lm3.mil.id.quad, ci = TRUE)

##Export p-values
p.val10<-cbind(summary(lm3.state.quad)$coefficients[,4],summary(lm3.rebel.quad)$coefficients[,4],summary(lm3.mil.pol.quad)$coefficients[,4],summary(lm3.mil.id.quad)$coefficients[,4])
round(p.val10, digits = 3)

#######################
###Remove Big Cities###
#######################
#subset data without areas within 15 minutes of big cities (50,000 or more residents)
full.1996.2019.ncity <- subset(full.1996.2019, ttime_zero!=1)
######Armed conflict
####State
lm3.state.ncity<-felm(formula=acled_battle_state ~ 
                        log.nl + logged.pop +
                        lagacled_battle_state + t  +
                        p_anom+spei+outbreak+t_anom+
                        logLifeExpectancy+GovEff+logGDPpc
                      |gid+month|0|gid,
                      data=full.1996.2019.ncity)
summary(lm3.state.ncity)
####Rebel
lm3.rebel.ncity<-felm(formula=acled_battle_rebel ~ 
                        log.nl + logged.pop +
                        lagacled_battle_rebel + t  +
                        p_anom+spei+outbreak+t_anom+
                        logLifeExpectancy+GovEff+logGDPpc
                      |gid+month|0|gid,
                      data=full.1996.2019.ncity)
summary(lm3.rebel.ncity)

######Social conflict
###Political
lm3.mil.pol.ncity<-felm(formula=acled_battle_polmil ~ 
                          log.nl + logged.pop +
                          lagacled_battle_polmil + t  +
                          p_anom+spei+outbreak+t_anom+
                          logLifeExpectancy+GovEff+logGDPpc
                        |gid+month|0|gid,
                        data=full.1996.2019.ncity)
summary(lm3.mil.pol.ncity)
###Identity
lm3.mil.id.ncity<-felm(formula=acled_battle_idmil ~ 
                         log.nl + logged.pop +
                         lagacled_battle_idmil + t  +
                         p_anom+spei+outbreak+t_anom+
                         logLifeExpectancy+GovEff+logGDPpc
                       |gid+month|0|gid,
                       data=full.1996.2019.ncity)
summary(lm3.mil.id.ncity)

###Export to LaTex 
stargazer(lm3.state.ncity,lm3.rebel.ncity,lm3.mil.pol.ncity, lm3.mil.id.ncity, ci = TRUE)

##Export p-values
p.val1<-cbind(summary(lm3.state.ncity)$coefficients[,4],summary(lm3.rebel.ncity)$coefficients[,4],summary(lm3.mil.pol.ncity)$coefficients[,4],summary(lm3.mil.id.ncity)$coefficients[,4])
round(p.val1, digits = 3)

